package com.community.controller;

import com.community.entity.Student;
import com.community.service.MajorService;
import com.community.service.StudentService;
import com.community.util.Result;
import com.community.util.Search;
import com.feng.fengDUtil.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/student")
public class StudentAction {
    @Autowired
    private StudentService studentService;

    @Autowired
    private MajorService majorService;


    @RequestMapping(value = "/list")
    public Result list(Page page, Search search) {
        studentService.query(page,search);
        return Result.success(page);
    }

    @RequestMapping(value = "/listIntentions")
    public Result listIntentions(Page page, Search search) {
        majorService.query(page,search);
        return Result.success(page);
    }

    @RequestMapping(value = "/save")
    public Result save(@RequestBody Student student) {
        studentService.saveOrUpdate(student);
        return Result.success(student);
    }

    @RequestMapping(value = "/setVip")
    public Result setVip(String id) {
        studentService.setVip(id);
        return Result.success();
    }


}
